package model;

import java.sql.SQLException;
import java.util.Calendar;
import java.util.List;

import managers.EsemenyNaploManager;
import managers.EsemenyNaploManagerImpl;
import managers.EszkozManager;
import managers.EszkozManagerImpl;
import managers.FoglalasManager;
import managers.FoglalasManagerImpl;
import managers.FoglaloManager;
import managers.FoglaloManagerImpl;
import managers.OperatorManager;
import managers.OperatorManagerImpl;
import managers.TeremManager;
import managers.TeremManagerImpl;
import managers.TipusManager;
import managers.TipusManagerImpl;
import workspace.Workspace;
import beans.Esemeny;
import beans.Eszkoz;
import beans.Foglalas;
import beans.Foglalo;
import beans.Operator;
import beans.Terem;
import beans.Tipus;

public class TeremnyilvantartasProvider {

	private OperatorManager operatorManager = new OperatorManagerImpl();
	private FoglalasManager foglalasManager = new FoglalasManagerImpl();
	private EszkozManager eszkozManager = new EszkozManagerImpl();
	private TipusManager tipusManager = new TipusManagerImpl();
	private TeremManager teremManager = new TeremManagerImpl();
	private FoglaloManager foglaloManager = new FoglaloManagerImpl();
	private EsemenyNaploManager esemenyNaploManager = new EsemenyNaploManagerImpl();

	public List<Foglalas> loadMindenFoglalasNaptol(Workspace workspace,
			Calendar startNap) throws SQLException {
		Calendar from = Calendar.getInstance();
		from.setTime(startNap.getTime());
		from.set(Calendar.HOUR_OF_DAY, 0);
		from.set(Calendar.MINUTE, 0);
		from.set(Calendar.SECOND, 0);
		from.set(Calendar.MILLISECOND, 0);
		return foglalasManager.loadFoglalasFromDate(workspace, from);
	}

	public List<Eszkoz> loadMindenEszkoz(Workspace workspace)
			throws SQLException {
		return eszkozManager.loadEszkozLista(workspace);
	}

	public List<Foglalo> loadMindenFoglalo(Workspace workspace)
			throws SQLException {
		return foglaloManager.loadFoglaloLista(workspace);
	}

	public List<Terem> loadMindenTerem(Workspace workspace) throws SQLException {
		return teremManager.loadTeremLista(workspace);
	}

	public List<Tipus> loadMindenTipus(Workspace workspace) throws SQLException {
		return tipusManager.loadTipusLista(workspace);
	}

	public List<Esemeny> loadEsemenyNaplo(Workspace workspace)
			throws SQLException {
		return esemenyNaploManager.loadEsemenyNaplo(workspace);
	}

	public Foglalas insertFoglalas(Workspace workspace, Foglalas foglalas)
			throws SQLException {
		return foglalasManager.insertFoglalas(workspace, foglalas);
	}

	public Foglalas updateFoglalas(Workspace workspace, Foglalas foglalas)
			throws SQLException {
		return foglalasManager.updateFoglalas(workspace, foglalas);
	}

	public Foglalo insertFoglalo(Workspace workspace, Foglalo newFoglalo)
			throws SQLException {
		return foglaloManager.insertFoglalo(workspace, newFoglalo);
	}

	public Foglalo updateFoglalo(Workspace workspace, Foglalo newFoglalo)
			throws SQLException {
		return foglaloManager.updateFoglalo(workspace, newFoglalo);
	}

	public boolean deleteFoglalo(Workspace workspace, long userId)
			throws SQLException {
		return foglaloManager.deleteFoglalo(workspace, userId);
	}

	public Terem insertTerem(Workspace workspace, Terem newTerem)
			throws SQLException {
		return teremManager.insertTerem(workspace, newTerem);
	}

	public Terem updateTerem(Workspace workspace, Terem newTerem)
			throws SQLException {
		return teremManager.updateTerem(workspace, newTerem);
	}

	public boolean deleteTerem(Workspace workspace, long teremId)
			throws SQLException {
		return teremManager.deleteTerem(workspace, teremId);
	}

	public Tipus insertTipus(Workspace workspace, Tipus newTipus)
			throws SQLException {
		return tipusManager.insertTipus(workspace, newTipus);
	}

	public Tipus updateTipus(Workspace workspace, Tipus newTipus)
			throws SQLException {
		return tipusManager.updateTipus(workspace, newTipus);
	}

	public boolean deleteTipus(Workspace workspace, long tipusId)
			throws SQLException {
		return tipusManager.deleteTipus(workspace, tipusId);
	}

	public Eszkoz insertEszkoz(Workspace workspace, Eszkoz newEszkoz)
			throws SQLException {
		return eszkozManager.insertEszkoz(workspace, newEszkoz);
	}

	public Eszkoz updateEszkoz(Workspace workspace, Eszkoz newEszkoz)
			throws SQLException {
		return eszkozManager.updateEszkoz(workspace, newEszkoz);
	}

	public boolean deleteEszkoz(Workspace workspace, long eszkozId)
			throws SQLException {
		return eszkozManager.deleteEszkoz(workspace, eszkozId);
	}

	public Operator insertOperator(Workspace workspace, Operator newOperator)
			throws SQLException {
		return operatorManager.insertOperator(workspace, newOperator);
	}

	public Operator updateOperator(Workspace workspace, Operator newOperator)
			throws SQLException {
		return operatorManager.updateOperator(workspace, newOperator);
	}

	public boolean deleteOperator(Workspace workspace, long operatorId)
			throws SQLException {
		return operatorManager.deleteOperator(workspace, operatorId);
	}

	public Operator loadOperatorByUsername(Workspace workspace, String userName)
			throws SQLException {
		return operatorManager
				.loadOperatorByUsername(workspace, userName, true);
	}

	public List<Operator> loadOperatorLista(Workspace workspace)
			throws SQLException {
		return operatorManager.loadOperatorLista(workspace);
	}

	public boolean deleteFoglalas(Workspace workspace, Foglalas deletedFoglalas)
			throws SQLException {
		return foglalasManager.deleteFoglalas(workspace, deletedFoglalas);
	}
}
